package model;

/**
 * This is the Spare Part class. This class contain the minimumAmount of part and the ID of every part.
 * <br>@author George
 */
public class SparePart implements Comparable<SparePart> {
	private int iDnumber;
	private StorageArea drawer;
	private String sketch;
	private int minimumAmount;
	private int actualAmount;

	/**
	 * <code>  SparePart sparePart = new SparePart(idNumber, drawer, sketch); </code>
	 * @author George
	 * @param int idNumber=The ID number
	 *  </br> StorageArea drawer = specific place in the Storage Area
	 *  </br> String sketch=The link to the sketch/drawing 
	 */
	public SparePart(int idNumber, StorageArea drawer, String sketch) {
		this.iDnumber = idNumber;
		this.setDrawer(drawer);
		this.sketch = sketch;
	}

	public int getIDnumber() {
		return iDnumber;
	}

	public StorageArea getDrawer() {
		return drawer;
	}

	public String getSketch() {
		if ( sketch != null)
		return sketch;
		else return "N/A";
	}

	public int getMinimumAmount() {
		return minimumAmount;
	}

	public int getAmount() {
		return actualAmount;
	}

	public void setIDnumber(int dnumber) {
		iDnumber = dnumber;
	}

	public void setDrawer(StorageArea drawer) {
		this.drawer = drawer;
	}

	public void setSketch(String sketch) {
		this.sketch = sketch;
	}

	public void setMinimumAmount(int minimumAmount) {
		this.minimumAmount = minimumAmount;
	}

	public void setAmount(int amount) {
		this.actualAmount = amount;
	}

	public void updateSparePart(int idNumber, StorageArea drawer,
			String sketch, int minimumAmount, int actualAmount) {
		this.iDnumber = idNumber;
		this.setDrawer(drawer);
		this.sketch = sketch;
		this.minimumAmount = minimumAmount;
		this.actualAmount = actualAmount;
	}

	//------------------------------------------------------
	
	public String toString() {
		return "Code: " + iDnumber;
	}

	//Do we  need the compareTo method for the sortSparePart()
	//Are we going to have a sortSparePart();
	@Override
	public int compareTo(SparePart spare) {
		int result = 0;
		int checkID = ((SparePart) spare).getIDnumber();
		if (iDnumber == checkID) {
			result = iDnumber - (checkID);
		}
		return result;
	}

}
